package com.dsjy.yf.address.entity.query;

import com.dsjy.yf.address.entity.myenum.TableEnum;
import lombok.Data;

/**
 * @author whj
 * @version 1.0
 * @date 2021-03-11 14:48
 */
@Data
public class AdminDeleteQuery {
    private String tableName;
    private Integer id;
    private Boolean isDelete;

    public boolean isNotNull() {
        return tableName != null && id != null && isDelete != null;
    }

    /**
     * 防止sql注入L
     *
     * @return
     */
    public boolean nameIsSafe() {
        if (TableEnum.COUNTY.getTableName().equals(this.tableName)) {
            return true;
        } else if (TableEnum.EXCLUSIVEZONE.getTableName().equals(this.tableName)) {
            return true;
        } else if (TableEnum.POI.getTableName().equals(this.tableName)) {
            return true;
        } else if (TableEnum.TOWN.getTableName().equals(this.tableName)) {
            return true;
        } else if (TableEnum.COMMUNITY.getTableName().equals(this.tableName)) {
            return true;
        } else if (TableEnum.VILLAGE.getTableName().equals(this.tableName)) {
            return true;
        } else if (TableEnum.STREET.getTableName().equals(this.tableName)) {
            return true;
        } else if (TableEnum.BUILDING.getTableName().equals(this.tableName)) {
            return true;
        } else if (TableEnum.YARD.getTableName().equals(this.tableName)) {
            return true;
        } else if (TableEnum.YARDROAD.getTableName().equals(this.tableName)) {
            return true;
        } else {
            return TableEnum.SUBAREA.getTableName().equals(this.tableName);
        }
    }
}
